{include file="../application/mobile/view/header.html" /}
</head>
<body>

<div class="bui-page">
    <header class="bui-bar">
        <div class="bui-bar-left">
            <a class="bui-btn" onclick="bui.back();"><i class="icon-back"></i></a>
        </div>
        <div class="bui-bar-main">测试题</div>
        <div class="bui-bar-right">
            <!-- 右边按钮位置 -->
        </div>
    </header>
    <main>
        <!-- 正文内容 -->
        <!-- 搜索条控件结构 -->
		<div id="searchbar" class="bui-searchbar bui-box">
            <div class="span1">
    			<div class="bui-input">
    				<i class="icon-search"></i>
    				<input type="search" value="" placeholder="请输入题目名"/>
                </div>
            </div>
            <div class="btn-search">搜索</div>
		</div>
		<!-- 列表控件结构 -->
		<div id="scrollSearch" class="bui-scroll">
			<div class="bui-scroll-head"></div>
			<div class="bui-scroll-main">
				<ul class="bui-list">
                    
				</ul> 
			</div>
			<div class="bui-scroll-foot"></div>
		</div>

    </main>
    <footer>
        <!-- 底部内容 此处内容固定在页面底部 -->
    </footer>
</div>


{include file="../application/mobile/view/footer.html" /}
<script>
        bui.ready(function () {
            var uiList = bui.list({
            id: "#scrollSearch",
            url: "question_list",
            field: {
                data:"data",
                err:"err",
                content:"content"
            },
            data: {
                "keyword":''
            },
            page:1,
            pageSize:10,
            template: function (data) {
                var html = "";
                data.map(function(el, index) {

                    html +=`<li class="bui-btn bui-box" href="/index.php/mobile/questions/question?question_id=${el.id}">
                            <div class="span1">
                                <h3 class="item-title">${el.question_name}</h3>
                            </div>
                            <span class="price">${el.created}</span>
                    </li>`
                });

                return html;
            }
        });

    // var n = 0;
    //搜索条的初始化
    var uiSearchbar = bui.searchbar({
        id:"#searchbar",
        onInput: function(e,keyword) {
            //实时搜索
            // console.log(++n)
        },
        onRemove: function(e,keyword) {
            //删除关键词需要做什么其它处理
            // console.log(keyword);
        },
        callback: function (e,keyword) {
            
            if( uiList ){
                
                //点击搜索清空数据
                uiList.empty();
                // 重新初始化数据
                uiList.init({
                    page: 1,
                    data: {
                        "keyword":keyword
                    }
                });
                
            }
        }

    });
 });
    bui.btn({id:".bui-page",handle:".bui-btn,a"}).load();

</script>
</body>
</html>